﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Business;

namespace University.Workshop.Presenters.CollectControl
{
    public class PresenterReadPayment
    {
        IReadPaymentView view;
        Model.Payment paymentToRead = new Model.Payment();

        public PresenterReadPayment(IReadPaymentView view, Model.Payment payment)
        {
            this.view = view;
            this.paymentToRead = payment;
            UpdateViewData();
        }

        public void UpdateViewData()
        {
            view.TotalAmount = paymentToRead.TotalAmount;
            view.PaymentDate = paymentToRead.PaymentDate;

            Model.Kardex kardex = new Model.Kardex { KardexId = paymentToRead.KardexId };
            kardex = ManagerKardex.GetKardexByKardexId(kardex);

            view.ClientId = kardex.ClientId;

            Model.Person socio = new Model.Person { PersonId = kardex.ClientId };
            socio = ManagerPerson.GetPersonByPersonId(socio);

            view.Names = socio.Names + " " + socio.LastNames;

            view.CollectFinded = ManagerCollectControl.SearchCollectsByPaymentId(paymentToRead);
        }
    }
}
